#include "navigatebar.h"
#include <QStandardPaths>
#include <QGSettings>
#include <QPainter>
#include <QProxyStyle>
#include <QPainterPath>
#include <QPalette>
#include <QGraphicsDropShadowEffect>
#include <QColor>
#include <QStyleOption>
#include <QDebug>

NavigateBar::NavigateBar(QWidget *parent) : QWidget(parent)
{
    this->setAutoFillBackground(true);
    this->setBackgroundRole(QPalette::Window);
    this->setProperty("useSystemStyleBlur",true);
    this->setAttribute(Qt::WA_TranslucentBackground,true);
}
void NavigateBar::changeTrans(double trans)
{
    m_tran = trans;//m_pGsettingControlTrans->get("transparency").toDouble() * 255;
    qDebug() << "透明度调整为：" << m_tran;
    this->repaint();
}
void NavigateBar::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    p.setPen(Qt::NoPen);
    QColor color = palette().color(QPalette::Window);
    // QColor color = palette().color(QPalette::Window);
    color.setAlpha(m_tran);
    QPalette pal(this->palette());
    pal.setColor(QPalette::Base,QColor(color));
    this->setPalette(pal);
    QBrush brush =QBrush(color);
    p.setBrush(brush);
    p.drawRoundedRect(opt.rect,0,0);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
